<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<input type="button" value="随机发水果" onclick="sendFruits();" /> 本次发的水果是：
		<span id="fruit"></span>
		<script type="text/javascript">
			function sendFruits(){

				var arr = ["苹果", "西瓜", "水晶梨", "桃子", "葡萄", "橘子", "榴莲", "哈密瓜", "橙子"];

				var num = Math.ceil(Math.random() * 9)-1;

				document.getElementById("fruit").innerHTML = arr[num];

			}
		</script>

	</body>

</html>